package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.service.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.plaf.PanelUI;

@Api(tags = "数据统计相关")
@RestController
@RequestMapping
public class StatisticsController {

    @Autowired
    StatisticsService statisticsService;

    @ApiOperation("获取首页小区数量，设备数量，会员数量，电卡数量")
    @GetMapping("/index-info/count")
    public AjaxResult indexInfoCount(){
        return AjaxResult.success(statisticsService.indexInfoCount());
    }

    @ApiOperation("获取设备分布")
    @GetMapping("/index-device/distribute")
    public AjaxResult indexDeviceDistribute(){
        return AjaxResult.success(statisticsService.indexDeviceDistribute());
    }

    @ApiOperation("获取首页插座统计")
    @GetMapping("/index-hole/statistics")
    public AjaxResult indexHole(){
        return AjaxResult.success(statisticsService.indexHole());
    }

    @ApiOperation("获取首页设备统计")
    @GetMapping("/index-device/statistics")
    public AjaxResult indexDevice(){
        return AjaxResult.success(statisticsService.indexDevice());
    }

    @ApiOperation("获取充值订单曲线")
    @GetMapping("/charge/curve")
    public AjaxResult chargeCurve(String month,Long communityId){
        return AjaxResult.success(statisticsService.chargeCurve(month,communityId));
    }

    @ApiOperation("获取充电订单曲线")
    @GetMapping("/recharge/curve")
    public AjaxResult rechargeCurve(String month,Long communityId){
        return AjaxResult.success(statisticsService.rechargeCurve(month,communityId));
    }

    @ApiOperation("获取订单数量 month 格式 应该为yyyyMMdd")
    @GetMapping("/day/order-count")
    public AjaxResult dayOrderCount(Integer type){
        return AjaxResult.success(statisticsService.dayOrderCount(type));
    }

    @ApiOperation("获取商家端首页数据")
    @GetMapping("/index/data")
    public AjaxResult indexData(){
        return AjaxResult.success(statisticsService.indexData());
    }

    @ApiOperation("设备使用排名 传communityId为小区下 不传为运营商下 ")
    @GetMapping("/device/use-rank")
    public AjaxResult deviceUseRank(Long communityId,String month){
        return AjaxResult.success(statisticsService.deviceUseRank(communityId,month));
    }

    @ApiOperation(value = "获取各种消费金额跟次数 ",notes = "rechargeCount = 钱包消费次数 rechargeCountMoney = 钱包消费金额 chargeMoney = 钱包充值金额 其他依此类推")
    @GetMapping("/consumption-pie")
    public AjaxResult consumptionPie(String month){
        return AjaxResult.success(statisticsService.consumptionPie(month));
    }
}
